﻿ <!--#include file="inc/common.asp" -->

 <%
    call openDB()
 
    if userDB<>blogDB and not isEmpty(userMgrUrl) and userMgrUrl<>"" then
        call closeDB()
        response.redirect userMgrUrl
    end if
    
    if userObj.userId="" then
        message("请先<a href=login.asp?blog_id=" & blogObj.blogId & "&cat_id=" & blogCatObj.catId &">登录</a>" )
        response.end
    end if    
    
    if request("actionType")="save" then
      if userDB=blogDB then '允许修改用户名
        dim user_name 
        user_name = filterHtml(request("user_name"))
        if user_name="" then
            message("用户名不能为空")
        elseif  user_name<>userObj.userName then
            dim tmpUserObj
            set tmpUserObj = new UserClass
            tmpUserObj.load(user_name)
            if tmpUserObj.isFound and tmpUserObj.userId<>userObj.userId then
                call closeDB()
                message("用户名<a href=user.asp?user_id=" & tmpUserObj.userId &">" & user_name & "</a>已经被其他用户注册")
                response.end
            end if
            
            dim rs_alias, isFound
            set rs_alias = Server.createObject("ADODB.Recordset")

            sql = " select userid, alias from user_alias where userid=" & userObj.userId
            rs_alias.open sql, conn, 1, 3
            
            isFound = false
            if not rs_alias.bof and not rs_alias.eof then
                rs_alias.find " alias='" & filterSQL(userObj.userName) & "' "
                if not rs_alias.bof and not rs_alias.eof then
                    isFound =true
                end if
            end if    
            if not isFound then
                rs_alias.addNew()
                rs_alias("userid") = userObj.userId
                rs_alias("alias") = userObj.userName 
                rs_alias.update()
            end if
            
            isFound = false
            if not rs_alias.bof and not rs_alias.eof then
                rs_alias.moveFirst()
                rs_alias.find " alias='" & filterSQL(user_Name) & "' "
                if not rs_alias.bof and not rs_alias.eof then
                    isFound =true
                end if
            end if    
            if not isFound then
                rs_alias.addNew()
                rs_alias("userid") = userObj.userId
                rs_alias("alias") = user_Name
                rs_alias.update()
            end if
            rs_alias.close()
            set rs_alias = nothing

            'userObj.userName = user_Name
            Session(GLOBAL_CACHE_PREFIX & "userName")=user_Name
          end if
        end if  ' end if userDB=blogDB then '修改用户名
        
        dim password_new 
        password_new =  filterHtml(request("userpassword"))
        if password_new<>"" then
            if password_new<>filterHtml(request("password2")) then
                message("两次输入的密码不匹配")
            else    
                password_new=md5(password_new)
                if SUPPORT_MD5_16BITS and len(userObj.password)=16 and len(password_new)=32 then
                    password_new = mid(password_new,9,16)
                end if
                userObj.password=password_new
                Session(GLOBAL_CACHE_PREFIX & "password") = password_new
            end if
        end if    

        userObj.faceUrl= filterHtml(request("face_url"))
        userObj.email= filterHtml(request("useremail"))
        userObj.webUrl= filterHtml(request("homepage"))
        userObj.msn= filterHtml(request("MSN"))
        userObj.qq= filterHtml(request("OICQ"))
        userObj.sign= filterHtml(request("sign"))

        userObj.store()

        call closeDB
        message("用户资料修改成功")
        response.end
    end if
 %>
 <HTML><HEAD><TITLE><%=blogObj.blogTitle%></TITLE>
<META http-equiv=Content-Type content="text/html; charset=<%=DEFAULT_CHARSET%>">

<style type="text/css">
TD{
    font-size:x-small;
    color:#333333;letter-spacing : 1pt ;line-height :14pt
}

INPUT {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px dotted; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}
SELECT {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px dotted; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}
TEXTAREA {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px dotted; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}
BUTTON {
	BORDER-RIGHT: #98ccd0 1px dotted; BORDER-TOP: #98ccd0 1px dotted; FONT-SIZE: x-small; BORDER-LEFT: #98ccd0 1px dotted; COLOR: #666666; BORDER-BOTTOM: #98ccd0 1px solid; FONT-FAMILY: "Verdana"; BACKGROUND-COLOR: transparent
}

</style>

<script language=javascript>
function selectFace(){
    window.open("select_face.asp","select_fase","width=300px,height=400px,resizable,scrollbars");
}
</script>
</HEAD>
<BODY bgProperties=fixed topMargin=2 bgcolor=white onload="">
   <br><br>
   <form name=form1 action=userinfo.asp method=post>   
        <table width=450px border=1 cellspacing=0 cellpadding=4 bordercolordark=#FFFFFF bordercolorlight=#98ccd0  bordercolor=#98ccd0 align=center >
          <tr  bgcolor=#98ccd0 >
            <td align=center nowrap height=40px  colspan=2>-->> .::.::: <b><%=userObj.userName%> 修改资料</b>  :::.::. <<-- </td>       
          </tr>
          <tr> 
           <td nowrap>
           当前用户名：
            </td>   
           <td>
           <input type=input id=user_name name=user_name size=15 value="<%=userObj.userName%>" <% if userDB<>blogDB then response.write("disabled") end if %> >
            </td>   
          </tr>          
<%
    if userDB=blogDB then 
%>
          <tr> 
            <td nowrap>
              其他用户名：
            </td>   
            <td>
           <%
                dim count, i
                count = 0
                if isArray(userObj.aliases) then
                    count = ubound(userObj.aliases)
                end if
                if count>0 then
                    for i=0 to count-1
                        if i>0 then
                            response.write(", ")
                        end if
          %>
          <a href=# onclick="document.getElementById('user_name').value='<%=userObj.aliases(i)%>'"><%=userObj.aliases(i)%></a>
          <%
                    next
                end if
           %>
              &nbsp;
            </td>   
          </tr>                                                                                 
<%
    end if 
%>
          <tr> 
           <td nowrap>
           密码：
            </td>   
           <td>
           <input type=password name=userpassword size=15 > 如果不想修改密码请留空
            </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap>
           再次输入密码：
            </td>   
           <td>
           <input type=password name=password2 size=15 > 如果不想修改密码请留空
            </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap >
           头像：
            </td>   
           <td align=left>
               <input type=text name=face_url size=25 value="<%=userObj.faceUrl%>" onblur="document.getElementById('face_img').src=this.value" > 
               <input type=button value="选择" onclick="selectFace()">
               <img id=face_img align=center border=0 src="<%=userObj.faceUrl%>">
           </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap>
           电子邮件：
            </td>   
           <td>
           <input type=text name=useremail size=30 value="<%=userObj.email%>"> 
            </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap>
           个人主页：
            </td>   
           <td>
           <input type=text name=homepage size=30 value="<%=userObj.webUrl%>"> 
            </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap>
           MSN 帐号：
            </td>   
           <td>
           <input type=text name=MSN size=30 value="<%=userObj.msn%>"> 
            </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap>
           QQ  号码：
            </td>   
           <td>
           <input type=text name=OICQ size=30 value="<%=userObj.qq%>"> 
            </td>   
          </tr>                                                                                 
          <tr> 
           <td nowrap>
           签名：<br><i>不能超过 300 个字符 </i>
            </td>   
           <td>
           <textarea name=sign cols=40 rows=4><%=userObj.sign%></textarea> 
            </td>   
          </tr>                                                                                 
          <tr  bgcolor=#98ccd0 > 
           <td colspan=2>
            &nbsp;
            </td>   
          </tr>                                                                                 
          <tr>                                                                              
            <td align=center height=40px colspan=2  >  
               <input type=submit value=' 保存 ' > 
               <input type=button onclick='history.back()' value=' 后退 '> 
               <input type=button onclick='document.location="index.asp?blog_id=<%=blogObj.blogId%>&cat_id=<%=blogCatObj.catId%>&pageno=<%=request("pageno")%>"' value=' 返回 '> 
            </td>
          </tr>
        </table>

        <input type=hidden name=blog_id value=<%=blogObj.blogId%> >
        <input type=hidden name=cat_id value=<%=blogCatObj.catId%> >
        <input type=hidden name=pageno value=<%=request("pageno")%> >


        <input type=hidden name=actionType value="save" >
    </form>
</BODY>


</HTML>

<!--#include file="inc/end.asp" -->